<template>
	<view>
		<cu-custom bgColor="bg-gradual-blue" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">验证优惠券</block>
		</cu-custom>
		<view class="top-img">
			<image style="width: 128px; height: 128px;" src="https://skv4.oss-cn-hangzhou.aliyuncs.com/cityCard/sapp/%E4%BC%98%E6%83%A0%20(1).png" mode="widthFix" class="response"></image>
		</view>
		<form class="form">
			<view class="cu-form-group">
				<view class="title">卡号</view>
				<input placeholder="可以输入卡号" type="text" :value="cardId" @confirm="getCardInfo(this.cardId)" confirm-type="done"></input>
				<button class='cu-btn bg-green shadow' @click="openQrcode">扫码</button>
			</view>
		</form>
	</view>
</template>

<script>
	import {updateDiscount} from '../../../../api/business.js'
	export default {
		data() {
			return {
				cardId:''
			}
		},
		methods: {
			openQrcode() {
				uni.scanCode({
					onlyFromCamera: true,
					success: (result) => {
						console.log(result, '扫码信息1')
						let data = result.result
						this.cardId = data
						this.checkCoupon(data)
					}
				})
			},
			checkCoupon(code){
				updateDiscount(code).then(ret=>{
					if(ret.data.errcode == 0) {
						this.$common.toast('验票成功')
					}else{
						this.$common.toast(ret.data.errmsg)
					}
				})
			}
		}
	}
</script>

<style>
.response{
	margin: 30px;
}
.top-img{
	display: flex;
	justify-content: center;

}
</style>
